package com.tarena.lbs.business.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tarena.lbs.business.pojo.po.BusinessPO;
import com.tarena.lbs.business.pojo.vo.BusinessVO;
import com.tarena.lbs.business.pojo.vo.StoreChainVO;
import com.tarena.lbs.business.pojo.vo.StoreVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BusinessMapper extends BaseMapper<BusinessPO> {
    @Select("select * from lbs_business where id=#{businessId}")
    BusinessVO busiStoreDetail(Integer businessId);

    @Select("select * from lbs_store where business_id=#{businessId}")
    List<StoreVO> storeDetail(Integer businessId);

    @Select("select s.id , s.store_name , c.link ,c.link_image as link_img ,c.link_status , b.business_name from lbs_store s join lbs_store_chain c on c.store_id = s.id join lbs_business b on b.id = s.business_id")
    List<StoreChainVO> getAll();

    @Update("update lbs_store_chain set link_status = if(link_status = '0' ,'1' ,'0') where store_id = #{id}")
    int updateStatus();
}
